<template>
    <div class="timeChange-warp">
      <span
          v-for="(item, i) in btnTitle"
          :key="i"
          :class="[isRadioButton ? 'time-btn-style' : 'time-style', isRadioButton ? active === item.code ? 'select-btn-style' : '' : active === item.code ? 'select-style' : '']"
          @click="clickTab(item.code)" :style="type=='small' ? {width: 'auto',padding: '0 16px'} : {}">
          {{item.name}}
      </span>
    </div>
</template>

<script>
    export default {
        name: 'timeChange',
        data () {
            return {
                active: this.btnTitle[0].code,
                cycle: null
            };
        },
        props: {
            btnTitle: {
                type: Array,
                default: () => []
            },
            isRadioButton: {
                type: Boolean,
                default: () => false
            },
            type: String
        },
        mounted () {
          
        },
        methods: {
            clickTab (val) {
                this.active = val;
                this.$emit('clickTab', this.active);
            }
        }
    }
</script>

<style scoped lang="scss">
.timeChange-warp {
    box-sizing: border-box;
    width: 100%;
    font-size: 16px;
    overflow: hidden;
    margin-top: 16px;
    .time-style {
        cursor: pointer;
        display: inline-block;
        font-weight: bolder;
        min-width: 30px;
        text-align: center;
        padding: 3px 15px;
        color: rgba(34, 39, 16, 0.5);
    }
    .time-btn-style{
        cursor: pointer;
        display: inline-block;
        font-weight: 500;
        min-width: 30px;
        text-align: center;
        color: #4496ff;
        background: #edf2fe;
        width: calc(20% - 10px);
        height: 36px;
        line-height: 36px;
        margin:  5px;
        border-radius: 6px;
    }
    .select-style {
        border-bottom: 4px solid #1c8de0;
        color: black;
    }
    .select-btn-style{
        background: #0b82ff;
        color: #fff;
        font-weight: 900;
    }
}
</style>
